package 力扣;

import java.util.ArrayList;

/**
 * @author yyq
 * @create 2022-06-06 20:33
 */
public class leetcode53 {
    public int maxSubArray(int[] nums) {
        int count = 0; // 用来记录局部最大值
        int result = Integer.MIN_VALUE ; // 用来记录全局最大值
        for (int i=0;i<nums.length;i++){
            count = count +nums[i];
            if(count>result) result=count;
            if(count<0) count=0;
        }
        return result;

    }

}
